/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2013
 */

package org.teacup.eightdays.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import org.teacup.eightdays.model.*;
import org.teacup.eightdays.dao.*;
import org.teacup.eightdays.service.*;
import org.teacup.eightdays.vo.query.*;

/**
 * @author Abner email:521yexu2008(a)163.com
 * @version 1.0
 * @since 1.0
 */

@Entity
@Table(name = "memberinfo")
public class Memberinfo extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "Memberinfo";
	public static final String ALIAS_MEMBERINFO_ID = "ID";
	public static final String ALIAS_LOGINNAME = "登陆账号";
	public static final String ALIAS_LOGIN_PASSWORD = "登陆密码";
	public static final String ALIAS_SEX = "性别(男1 女0)";
	public static final String ALIAS_STATUS = "状态";
	public static final String ALIAS_DEPARTMENT_ID = "院系ID";
	public static final String ALIAS_CLASS_NAME = "班级名称";
	public static final String ALIAS_BRITHDAY = "生日";
	public static final String ALIAS_EMAIL = "Email";
	public static final String ALIAS_QQ_NUMBER = "QQ号码";
	public static final String ALIAS_MOBILE_NUMBER = "手机号码";
	public static final String ALIAS_NAME = "真实姓名";
	public static final String ALIAS_ADDRESS = "详细地址";
	public static final String ALIAS_MOBILE_APPROVE_STATUS = "手机认证状态";
	public static final String ALIAS_EMAIL_APPROVE_STATUS = "Email认证状态";
	public static final String ALIAS_REG_TIME = "注册时间";
	public static final String ALIAS_NOW_LOGIN_TIME = "本次登陆时间";
	public static final String ALIAS_LAST_LOGIN_TIME = "上次登陆时间";
	
	//date formats
	public static final String FORMAT_BRITHDAY = DATE_FORMAT;
	public static final String FORMAT_REG_TIME = DATE_FORMAT;
	public static final String FORMAT_NOW_LOGIN_TIME = DATE_FORMAT;
	public static final String FORMAT_LAST_LOGIN_TIME = DATE_FORMAT;
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * ID       db_column: memberinfo_id 
     */ 	
	
	private java.lang.Long memberinfoId;
    /**
     * 登陆账号       db_column: loginname 
     */ 	
	@NotBlank @Length(max=255)
	private java.lang.String loginname;
    /**
     * 登陆密码       db_column: login_password 
     */ 	
	@NotBlank @Length(max=255)
	private java.lang.String loginPassword;
    /**
     * 性别(男1 女0)       db_column: sex 
     */ 	
	
	private java.lang.Integer sex;
    /**
     * 状态       db_column: status 
     */ 	
	@NotNull 
	private java.lang.Integer status;
    /**
     * 院系ID       db_column: department_id 
     */ 	
	
	private java.lang.Long departmentId;
    /**
     * 班级名称       db_column: class_name 
     */ 	
	@Length(max=200)
	private java.lang.String className;
    /**
     * 生日       db_column: brithday 
     */ 	
	
	private java.util.Date brithday;
    /**
     * Email       db_column: email 
     */ 	
	@Email @Length(max=255)
	private java.lang.String email;
    /**
     * QQ号码       db_column: qq_number 
     */ 	
	@Length(max=100)
	private java.lang.String qqNumber;
    /**
     * 手机号码       db_column: mobile_number 
     */ 	
	@Length(max=255)
	private java.lang.String mobileNumber;
    /**
     * 真实姓名       db_column: name 
     */ 	
	@Length(max=50)
	private java.lang.String name;
    /**
     * 详细地址       db_column: address 
     */ 	
	@Length(max=500)
	private java.lang.String address;
    /**
     * 手机认证状态       db_column: mobile_approve_status 
     */ 	
	
	private java.lang.Boolean mobileApproveStatus;
    /**
     * Email认证状态       db_column: email_approve_status 
     */ 	
	@Email
	private java.lang.Boolean emailApproveStatus;
    /**
     * 注册时间       db_column: reg_time 
     */ 	
	
	private java.util.Date regTime;
    /**
     * 本次登陆时间       db_column: now_login_time 
     */ 	
	
	private java.util.Date nowLoginTime;
    /**
     * 上次登陆时间       db_column: last_login_time 
     */ 	
	
	private java.util.Date lastLoginTime;
	//columns END


	public Memberinfo(){
	}

	public Memberinfo(
		java.lang.Long memberinfoId
	){
		this.memberinfoId = memberinfoId;
	}

	

	public void setMemberinfoId(java.lang.Long value) {
		this.memberinfoId = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "increment")
	@Column(name = "memberinfo_id", unique = true, nullable = false, insertable = true, updatable = true, length = 19)
	public java.lang.Long getMemberinfoId() {
		return this.memberinfoId;
	}
	
	@Column(name = "loginname", unique = false, nullable = false, insertable = true, updatable = true, length = 255)
	public java.lang.String getLoginname() {
		return this.loginname;
	}
	
	public void setLoginname(java.lang.String value) {
		this.loginname = value;
	}
	
	@Column(name = "login_password", unique = false, nullable = false, insertable = true, updatable = true, length = 255)
	public java.lang.String getLoginPassword() {
		return this.loginPassword;
	}
	
	public void setLoginPassword(java.lang.String value) {
		this.loginPassword = value;
	}
	
	@Column(name = "sex", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getSex() {
		return this.sex;
	}
	
	public void setSex(java.lang.Integer value) {
		this.sex = value;
	}
	
	@Column(name = "status", unique = false, nullable = false, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getStatus() {
		return this.status;
	}
	
	public void setStatus(java.lang.Integer value) {
		this.status = value;
	}
	
	@Column(name = "department_id", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getDepartmentId() {
		return this.departmentId;
	}
	
	public void setDepartmentId(java.lang.Long value) {
		this.departmentId = value;
	}
	
	@Column(name = "class_name", unique = false, nullable = true, insertable = true, updatable = true, length = 200)
	public java.lang.String getClassName() {
		return this.className;
	}
	
	public void setClassName(java.lang.String value) {
		this.className = value;
	}
	
	@Transient
	public String getBrithdayString() {
		return DateConvertUtils.format(getBrithday(), FORMAT_BRITHDAY);
	}
	public void setBrithdayString(String value) {
		setBrithday(DateConvertUtils.parse(value, FORMAT_BRITHDAY,java.util.Date.class));
	}
	
	@Column(name = "brithday", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public java.util.Date getBrithday() {
		return this.brithday;
	}
	
	public void setBrithday(java.util.Date value) {
		this.brithday = value;
	}
	
	@Column(name = "email", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getEmail() {
		return this.email;
	}
	
	public void setEmail(java.lang.String value) {
		this.email = value;
	}
	
	@Column(name = "qq_number", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getQqNumber() {
		return this.qqNumber;
	}
	
	public void setQqNumber(java.lang.String value) {
		this.qqNumber = value;
	}
	
	@Column(name = "mobile_number", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getMobileNumber() {
		return this.mobileNumber;
	}
	
	public void setMobileNumber(java.lang.String value) {
		this.mobileNumber = value;
	}
	
	@Column(name = "name", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
	public java.lang.String getName() {
		return this.name;
	}
	
	public void setName(java.lang.String value) {
		this.name = value;
	}
	
	@Column(name = "address", unique = false, nullable = true, insertable = true, updatable = true, length = 500)
	public java.lang.String getAddress() {
		return this.address;
	}
	
	public void setAddress(java.lang.String value) {
		this.address = value;
	}
	
	@Column(name = "mobile_approve_status", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public java.lang.Boolean getMobileApproveStatus() {
		return this.mobileApproveStatus;
	}
	
	public void setMobileApproveStatus(java.lang.Boolean value) {
		this.mobileApproveStatus = value;
	}
	
	@Column(name = "email_approve_status", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public java.lang.Boolean getEmailApproveStatus() {
		return this.emailApproveStatus;
	}
	
	public void setEmailApproveStatus(java.lang.Boolean value) {
		this.emailApproveStatus = value;
	}
	
	@Transient
	public String getRegTimeString() {
		return DateConvertUtils.format(getRegTime(), FORMAT_REG_TIME);
	}
	public void setRegTimeString(String value) {
		setRegTime(DateConvertUtils.parse(value, FORMAT_REG_TIME,java.util.Date.class));
	}
	
	@Column(name = "reg_time", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public java.util.Date getRegTime() {
		return this.regTime;
	}
	
	public void setRegTime(java.util.Date value) {
		this.regTime = value;
	}
	
	@Transient
	public String getNowLoginTimeString() {
		return DateConvertUtils.format(getNowLoginTime(), FORMAT_NOW_LOGIN_TIME);
	}
	public void setNowLoginTimeString(String value) {
		setNowLoginTime(DateConvertUtils.parse(value, FORMAT_NOW_LOGIN_TIME,java.util.Date.class));
	}
	
	@Column(name = "now_login_time", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public java.util.Date getNowLoginTime() {
		return this.nowLoginTime;
	}
	
	public void setNowLoginTime(java.util.Date value) {
		this.nowLoginTime = value;
	}
	
	@Transient
	public String getLastLoginTimeString() {
		return DateConvertUtils.format(getLastLoginTime(), FORMAT_LAST_LOGIN_TIME);
	}
	public void setLastLoginTimeString(String value) {
		setLastLoginTime(DateConvertUtils.parse(value, FORMAT_LAST_LOGIN_TIME,java.util.Date.class));
	}
	
	@Column(name = "last_login_time", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public java.util.Date getLastLoginTime() {
		return this.lastLoginTime;
	}
	
	public void setLastLoginTime(java.util.Date value) {
		this.lastLoginTime = value;
	}
	
	
	private Set deliveryAddresss = new HashSet(0);
	public void setDeliveryAddresss(Set<DeliveryAddress> deliveryAddress){
		this.deliveryAddresss = deliveryAddress;
	}
	
	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "memberinfo")
	public Set<DeliveryAddress> getDeliveryAddresss() {
		return deliveryAddresss;
	}
	
	private Set orderinfos = new HashSet(0);
	public void setOrderinfos(Set<Orderinfo> orderinfo){
		this.orderinfos = orderinfo;
	}
	
	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "memberinfo")
	public Set<Orderinfo> getOrderinfos() {
		return orderinfos;
	}
	
	private Department department;
	public void setDepartment(Department department){
		this.department = department;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "department_id",nullable = false, insertable = false, updatable = false) 
	})
	public Department getDepartment() {
		return department;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("MemberinfoId",getMemberinfoId())
			.append("Loginname",getLoginname())
			.append("LoginPassword",getLoginPassword())
			.append("Sex",getSex())
			.append("Status",getStatus())
			.append("DepartmentId",getDepartmentId())
			.append("ClassName",getClassName())
			.append("Brithday",getBrithday())
			.append("Email",getEmail())
			.append("QqNumber",getQqNumber())
			.append("MobileNumber",getMobileNumber())
			.append("Name",getName())
			.append("Address",getAddress())
			.append("MobileApproveStatus",getMobileApproveStatus())
			.append("EmailApproveStatus",getEmailApproveStatus())
			.append("RegTime",getRegTime())
			.append("NowLoginTime",getNowLoginTime())
			.append("LastLoginTime",getLastLoginTime())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getMemberinfoId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof Memberinfo == false) return false;
		if(this == obj) return true;
		Memberinfo other = (Memberinfo)obj;
		return new EqualsBuilder()
			.append(getMemberinfoId(),other.getMemberinfoId())
			.isEquals();
	}
}

